<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:l="clr-namespace:UIControls">

    <SolidColorBrush x:Key="SearchTextBox_Background" Color="White" />
    <SolidColorBrush x:Key="SearchTextBox_Foreground" Color="Black" />
    <LinearGradientBrush x:Key="SearchTextBox_Border" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFABADB3" Offset="0.05" />
        <GradientStop Color="#FFE2E3EA" Offset="0.07" />
        <GradientStop Color="#FFE3E9EF" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_BorderMouseOver" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FF5C97C1" Offset="0.05" />
        <GradientStop Color="#FFB9D7EB" Offset="0.07" />
        <GradientStop Color="#FFC7E2F1" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBorder" Color="White" />
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBackground" Color="White" />
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBorder_MouseOver" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFE5F4FC" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBackground_MouseOver" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFE7F5FD" Offset="0" />
        <GradientStop Color="#FFD2EDFC" Offset="0.5" />
        <GradientStop Color="#FFB6E3FD" Offset="0.51" />
        <GradientStop Color="#FF9DD5F3" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBorder_MouseDown" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFE5F4FC" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SearchTextBox_SearchIconBackground_MouseDown" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FFE7F5FD" Offset="0" />
        <GradientStop Color="#FFD2EDFC" Offset="0.5" />
        <GradientStop Color="#FFB6E3FD" Offset="0.51" />
        <GradientStop Color="#FF9DD5F3" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="SearchTextBox_LabelTextColor" Color="Gray" />

    <Style x:Key="{x:Type l:SearchTextBox}" TargetType="{x:Type l:SearchTextBox}">
        <Setter Property="Background" Value="{StaticResource SearchTextBox_Background}" />
        <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_Border}" />
        <Setter Property="Foreground" Value="{StaticResource SearchTextBox_Foreground}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="LabelText" Value="Search" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="LabelTextColor" Value="{StaticResource SearchTextBox_LabelTextColor}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type l:SearchTextBox}">
                    <Border x:Name="Border"
                  Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="LayoutGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                  Path=ActualHeight}" />
                            </Grid.ColumnDefinitions>
                            <ScrollViewer Margin="2" x:Name="PART_ContentHost" Grid.Column="0" />
                            <Label x:Name="LabelText"
                     Margin="2"
                     Grid.Column="0"
                     Foreground="{Binding RelativeSource={RelativeSource TemplatedParent},
                                          Path=LabelTextColor}"
                     Content="{Binding RelativeSource={RelativeSource TemplatedParent},
                                       Path=LabelText}"
                     Padding="2,0,0,0"
                     FontStyle="Italic" />
                            <Border x:Name="PART_SearchIconBorder"
                      Grid.Column="1"
                      BorderThickness="1"
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
                      BorderBrush="{StaticResource SearchTextBox_SearchIconBorder}"
                      Background="{StaticResource SearchTextBox_SearchIconBackground}">
                                <Image x:Name="SearchIcon"
                       Stretch="None"
                       Width="15"
                       Height="15" 
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="pack://application:,,,/UIControls;component/Images/search.png" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_BorderMouseOver}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_BorderMouseOver}" />
                        </Trigger>
                        <Trigger Property="HasText" Value="True">
                            <Setter Property="Visibility" TargetName="LabelText" Value="Hidden" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasText" Value="True" />
                                <Condition Property="SearchMode" Value="Instant" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Source"
                      TargetName="SearchIcon"
                      Value="pack://application:,,,/UIControls;component/Images/clear.png" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                           SourceName="PART_SearchIconBorder"
                           Value="True" />
                                <Condition Property="HasText" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush"
                      TargetName="PART_SearchIconBorder"
                      Value="{StaticResource SearchTextBox_SearchIconBorder_MouseOver}" />
                            <Setter Property="Background"
                      TargetName="PART_SearchIconBorder"
                      Value="{StaticResource SearchTextBox_SearchIconBackground_MouseOver}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="PART_SearchIconBorder" Value="True" />
                                <Condition Property="IsMouseLeftButtonDown" Value="True" />
                                <Condition Property="HasText" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Padding"
                      TargetName="PART_SearchIconBorder"
                      Value="2,0,0,0" />
                            <Setter Property="BorderBrush"
                      TargetName="PART_SearchIconBorder"
                      Value="{StaticResource SearchTextBox_SearchIconBorder_MouseOver}" />
                            <Setter Property="Background"
                      TargetName="PART_SearchIconBorder"
                      Value="{StaticResource SearchTextBox_SearchIconBackground_MouseOver}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type l:ContentTicker}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type l:ContentTicker}">
                    <Canvas x:Name="PART_ContentControl" 
                            HorizontalAlignment="Stretch" 
                            VerticalAlignment="Stretch" 
                            Width="{TemplateBinding Width}" 
                            Height="{TemplateBinding Height}"
                            Background="{TemplateBinding Background}">
                        <Canvas.Triggers>
                            <EventTrigger RoutedEvent="Canvas.Loaded">
                                <BeginStoryboard>
                                    <Storyboard x:Name="ContentTickerStoryboard" Storyboard.TargetProperty="(Canvas.Left)">
                                        <DoubleAnimation Storyboard.TargetName="PART_Content" RepeatBehavior="Forever" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Canvas.Triggers>
                        <ContentPresenter x:Name="PART_Content" 
                                          HorizontalAlignment="{TemplateBinding ContentControl.HorizontalAlignment}"
                                          VerticalAlignment="{TemplateBinding ContentControl.VerticalAlignment}"
                                          Content="{TemplateBinding ContentControl.Content}"
                                          ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" />
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94"/>

    <Style TargetType="l:AnimatedTabControl">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
        <Setter Property="Background" Value="#F9F9F9"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="l:AnimatedTabControl">

                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Border Grid.Row="1" BorderThickness="0" BorderBrush="#FFFFFFFF">
                            <TabPanel x:Name="HeaderPanel" HorizontalAlignment="Center" VerticalAlignment="Center" IsItemsHost="true" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabIndex="1"/>
                        </Border>

                        <Grid Grid.Row="1" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Viewport3D x:Name="vp3D" Visibility="Hidden" Width="Auto" Height="Auto">
                                <Viewport3D.Camera>
                                    <PerspectiveCamera x:Name="camera" Position="0,0,0.5" LookDirection="0,0,-1" FieldOfView="90" />
                                </Viewport3D.Camera>
                                <Viewport3D.Children>
                                    <ModelVisual3D>
                                        <ModelVisual3D.Content>
                                            <Model3DGroup>
                                                <DirectionalLight Color="#444" Direction="0,0,-1" />
                                                <AmbientLight Color="#BBB" />
                                            </Model3DGroup>
                                        </ModelVisual3D.Content>
                                    </ModelVisual3D>
                                    <ModelVisual3D>
                                        <ModelVisual3D.Content>
                                            <GeometryModel3D>
                                                <GeometryModel3D.Geometry>
                                                    <MeshGeometry3D  TriangleIndices="0,1,2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" Positions="-0.5,-0.5,0 0.5,-0.5,0 0.5,0.5,0 -0.5,0.5,0" />
                                                </GeometryModel3D.Geometry>
                                                <GeometryModel3D.Material>
                                                    <DiffuseMaterial>
                                                        <DiffuseMaterial.Brush>
                                                            <VisualBrush Visual="{Binding ElementName=BorderIn}" Stretch="Uniform" />
                                                        </DiffuseMaterial.Brush>
                                                    </DiffuseMaterial>
                                                </GeometryModel3D.Material>
                                                <GeometryModel3D.BackMaterial>
                                                    <DiffuseMaterial>
                                                        <DiffuseMaterial.Brush>
                                                            <VisualBrush Visual="{Binding ElementName=BorderIn}" Stretch="Uniform">
                                                                <VisualBrush.RelativeTransform>
                                                                    <ScaleTransform ScaleX="-1" CenterX="0.5" />
                                                                </VisualBrush.RelativeTransform>
                                                            </VisualBrush>
                                                        </DiffuseMaterial.Brush>
                                                    </DiffuseMaterial>
                                                </GeometryModel3D.BackMaterial>
                                                <GeometryModel3D.Transform>
                                                    <RotateTransform3D>
                                                        <RotateTransform3D.Rotation>
                                                            <AxisAngleRotation3D x:Name="rotate" Axis="0,3,0" Angle="0" />
                                                        </RotateTransform3D.Rotation>
                                                    </RotateTransform3D>
                                                </GeometryModel3D.Transform>
                                            </GeometryModel3D>
                                        </ModelVisual3D.Content>
                                    </ModelVisual3D>
                                </Viewport3D.Children>
                            </Viewport3D>
                            <Border x:Name="BorderOut" VerticalAlignment="Stretch">
                                <Border x:Name="BorderIn" VerticalAlignment="Stretch" Background="#00000000" >
                                    <Grid>
                                        <!--<Controls:RoundedBox Margin="10" />-->
                                        <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0"/>
                                    </Grid>
                                </Border>
                            </Border>
                        </Grid>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="l:AnimatedTabControl.SelectionChanging">
                            <BeginStoryboard>
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="vp3D"  Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                        <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="{x:Static Visibility.Hidden}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation To="0" Duration="0:0:0.05" Storyboard.TargetName="BorderOut" Storyboard.TargetProperty="Opacity" />
                                    <DoubleAnimation BeginTime="0:0:1.05" Duration="0:0:0.05" To="1" Storyboard.TargetName="BorderOut" Storyboard.TargetProperty="Opacity" />
                                    <Point3DAnimation To="0,0,1.1" From="0,0,0.5"  BeginTime="0:0:0.05" Duration="0:0:0.5" AutoReverse="True" DecelerationRatio="0.3"  Storyboard.TargetName="camera" 
                                            Storyboard.TargetProperty="(PerspectiveCamera.Position)" />
                                    <DoubleAnimation From="0" To="180" AccelerationRatio="0.3" DecelerationRatio="0.3" BeginTime="0:0:0.05" Duration="0:0:1"  Storyboard.TargetName="rotate" Storyboard.TargetProperty="Angle" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>


            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
